package cn.favebook.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.dbutils.QueryRunner;

import cn.favebook.Global;
import cn.favebook.bean.User;
import cn.favebook.db.WeiboDao;

/**
 * Servlet implementation class DelWeiboServlet
 */
@WebServlet("/zone/rm.do")
public class DelWeiboServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid = request.getParameter("id");
		String ajax = request.getParameter("ajax");
		int id;
		id = Integer.valueOf(sid).intValue();
		
		QueryRunner runner = (QueryRunner) request.getServletContext().getAttribute(Global.KEY_QUERY_RUNNER);
		try {
			WeiboDao.del(runner, id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(ajax != null && ajax.equals("true")) {
			response.setContentType("application/json");
			response.getWriter().println("{\"ok\": 1}");
		} else {
			response.sendRedirect("/favebook/mineindex.jsp");
		}
	}



}
